<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <eForm ref="form" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      v-loading="loading"
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :max-height="gridMaxHeight"
      :total="total"
      :show-page="false"
      grid-id="taskMngProcessGridId"
      @selection-change="handleGridSelectionChange">
      <DataGridColumnSlot prop="taskName" label="任务名称">
        <template slot-scope="scope">
          <edit :data="scope.row" :sup_this="sup_this" />
        </template>
      </DataGridColumnSlot>
      <DataGridColumn prop="chargerName" label="负责人" />
      <DataGridColumn prop="priority" label="优先级" />
      <el-table-column prop="taskStatus" label="任务状态">
        <template slot-scope="scope">
          <div v-for="item in dicts.bus_task_status" :key="item.id">
            <el-tag v-if="scope.row.taskStatus.toString() === item.dictCode" :type="item.attribute1">{{ item.dictName }}</el-tag>
          </div>
        </template>
      </el-table-column>
      <DataGridColumn prop="costTime" label="任务用时" />
      <DataGridColumnSlot prop="beginTaskDate" label="预计开始日期" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.beginTaskDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot prop="endTaskDate" label="预计结束日期" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTaskDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot prop="actualBeginTaskDate" label="实际开始日期" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualBeginTaskDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot prop="actualEndTaskDate" label="实际结束日期" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualEndTaskDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot prop="lastUpdateDate" label="最后更新时间" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateDate) }}</span>
        </template>
      </DataGridColumnSlot>
    </DataGridTable>
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
import edit from './module/edit'
import eForm from './module/form'
import initData from '@/mixins/initData'
import task from '@/api/crm/Task'

export default {
  components: { eHeader, eForm, edit },
  mixins: [initData],
  dictTypes: ['bus_task_status'],
  props: {
  },
  data() {
    return {
      delLoading: false,
      sup_this: this,
      busMaindata: {}
    }
  },
  created() {
    this.url = task.loadDataUrl()
    /* this.$nextTick(() => {
      this.resetQuery(true)
    })*/
  },
  mounted() {
  },
  methods: {
    parseTime,
    async beforeInit() {
      return true
    },
    initLoadDataByCode(busMainData) {
      this.busMainData = busMainData
      this.defaultParamBean.objectSysCode = busMainData.sysGenCode
      this.resetQuery(true)
    }
  }
}
</script>
